<link rel="stylesheet" href="/static/extends/layuimini/css/login.css">
<div id="container">
    <div></div>
    <div class="admin-login-background">
        <div class="admin-header">
            <span>跑腿儿</span>
        </div>
        <form class="layui-form" action="">
            <div>
                <i class="layui-icon layui-icon-username admin-icon"></i>
                <input type="text" name="move_user" placeholder="请输入用户名" autocomplete="off"
                       class="layui-input admin-input admin-input-username" value="">
            </div>
            <div>
                <i class="layui-icon layui-icon-password admin-icon"></i>
                <input type="password" name="move_pwd" placeholder="请输入密码" autocomplete="off"
                       class="layui-input admin-input" value="">
            </div>
            <div>
                <input type="text" name="captcha" placeholder="请输入验证码" autocomplete="off"
                       class="layui-input admin-input admin-input-verify" value="">
                <img class="admin-captcha" width="90" height="30" src="{:url('login/captcha')}"
                     onclick="this.src='{:url(\'login/captcha\')}?math='+Math.random();">

            </div>
            <button class="layui-btn admin-button" lay-submit="" lay-filter="login">登 陆</button>
        </form>
    </div>
</div>

<script>
    // layui.use(['form'], function () {
    var form = layui.form,
        layer = layui.layer;

    // 登录过期的时候，跳出ifram框架
    if (top.location != self.location) top.location = self.location;

    // 进行登录操作
    form.on('submit(login)', function (obj) {
        let data = obj.field;
        if (data.move_user == '') {
            layer.msg('用户名不能为空');
            return false;
        }
        if (data.move_pwd == '') {
            layer.msg('密码不能为空');
            return false;
        }
        if (data.captcha == '') {
            layer.msg('验证码不能为空');
            return false;
        }
        hadmin.http("{:url('checkLogin')}", data).then(function (res) {
            if (res.code == 1) {
                return layer.msg(res.msg, {icon: 6, shade: 0.5}, function () {
                    window.location.href = "{:url('index/index')}";
                })
            }
        });
        return false;
    });
    // });
</script>